package com.waya.web.browser.player;

import com.waya.web.browser.player.view.MediaPlayerLayout;
import com.waye.wanba.utils.APPLog;

/**
 * Created by JesseHev on 2018/1/18.
 * describe: 播放器Proxy
 */

public class PlayerProxy implements PlayerInterface {

    MediaPlayerLayout playerLayout;

    private static volatile PlayerProxy INSTANCE = null;

    public static PlayerProxy getInstance(MediaPlayerLayout playerLayout) {
        if (INSTANCE == null) {
            synchronized (PlayerProxy.class) {
                INSTANCE = new PlayerProxy(playerLayout);
            }
        }
        return INSTANCE;
    }

    private PlayerProxy(MediaPlayerLayout playerLayout) {
        this.playerLayout = playerLayout;
    }


    @Override
    public int setBreakpoint(int position) {
        return playerLayout.setBreakpoint(position);
    }

    @Override
    public int openDefaultPlayer(String urls) {
        return playerLayout.openDefaultPlayer(urls);
    }

    @Override
    public int setDisplay(int left, int top, int width, int height) {
        return playerLayout.setDisplay(left, top, width, height);
    }

    @Override
    public int setDataSourceList(String urls) {
        return playerLayout.setDataSourceList(urls);
    }

    @Override
    public int setDataSource(String url) {
        return playerLayout.setDataSource(url);
    }

    @Override
    public int start() {
        return playerLayout.start();
    }

    @Override
    public int play() {
        return playerLayout.play();
    }

    @Override
    public int pause() {
        return playerLayout.play();
    }

    @Override
    public int getDuration() {
        return playerLayout.getDuration();
    }

    @Override
    public int getCurrentPosition() {
        return playerLayout.getCurrentPosition();
    }

    @Override
    public int seekTo(int position) {
        return playerLayout.seekTo(position);
    }

    @Override
    public int fullScreen() {

        return playerLayout.fullScreen();
    }

    @Override
    public int exitFullScreen() {
        return playerLayout.exitFullScreen();
    }

    @Override
    public int release() {
        return playerLayout.release();
    }

    /////////////////////////////////////////////////
    @Override
    public void onError(String code, String msg) {
//        playerLayout.onError(code, msg);
        System.out.println(" onError===>" + code);
    }

    @Override
    public void onCompleted() {
//        playerLayout.onCompleted();
        System.out.println("onCompleted ===>");
    }

    @Override
    public void onExit() {
//        playerLayout.onExit();
        System.out.println("onExit ===>退出全屏");
    }
}
